package com.cskaoyan.service;

import com.cskaoyan.bean.po.*;
import com.cskaoyan.bean.vo.AdminDashboardVO;
import com.cskaoyan.mapper.MarketGoodsMapper;
import com.cskaoyan.mapper.MarketGoodsProductMapper;
import com.cskaoyan.mapper.MarketOrderMapper;
import com.cskaoyan.mapper.MarketUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wei
 * @since 2022/09/06 19:21
 */
@Service
public class IndexServiceImpl implements IndexService {
    @Autowired
    MarketUserMapper userMapper;
    @Autowired
    MarketGoodsMapper goodsMapper;
    @Autowired
    MarketOrderMapper orderMapper;
    @Autowired
    MarketGoodsProductMapper productMapper;

    @Override
    public AdminDashboardVO queryNum() {
        AdminDashboardVO adminDashboardVO = new AdminDashboardVO();
        long userNum = userMapper.countByExample(new MarketUserExample());
        adminDashboardVO.setUserTotal((int) userNum);
        long goodsNum = goodsMapper.countByExample(new MarketGoodsExample());
        adminDashboardVO.setGoodsTotal((int) goodsNum);
        long orderNum = orderMapper.countByExample(new MarketOrderExample());
        adminDashboardVO.setOrderTotal((int) orderNum);
        long productNum = productMapper.countByExample(new MarketGoodsProductExample());
        adminDashboardVO.setProductTotal((int) productNum);
        return adminDashboardVO;
    }
}

